package com.dpwgc.provider.controller;

import com.dpwgc.provider.model.Hunter;
import com.dpwgc.provider.service.HunterService;
import com.dpwgc.provider.utils.DateUtil;
import com.dpwgc.provider.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping(value = "/Hunter")
public class HunterController {

    @Autowired
    HunterService hunterService;
    @Autowired
    DateUtil dateUtil;

    /**
     * 创建猎人账号
     * @param
     * @return
     */
    @RequestMapping(value = "/createHunter",method = RequestMethod.POST)
    public ResultUtil<Object> createHunter(@RequestParam Map<String,String> params){
        Hunter hunter = new Hunter();
        hunter.setHunterUuid(params.get("userUuid"));
        hunter.setHunterName(params.get("hunterName"));
        hunter.setHunterUpdateTime(dateUtil.getDateTime());
        hunter.setHunterCreateTime(dateUtil.getDateTime());
        hunter.setHunterIdentity(params.get("hunterIdentity"));
        hunter.setHunterPhone(params.get("hunterPhone"));

        return hunterService.createHunterService(hunter);
    }

    /**
     * 取消猎人资质
     * @param
     * @return
     */
    @RequestMapping(value = "/deleHunter",method = RequestMethod.POST)
    public ResultUtil<Object> deleHunter(@RequestParam("hunterUuid") String hunterUuid){
        return hunterService.deleHunterService(hunterUuid);
    }

    /**
     * 获取猎人信息
     * @param
     * @return
     */
    @RequestMapping(value = "/getHunter",method = RequestMethod.POST)
    public ResultUtil<Object> getHunter(@RequestParam("hunterUuid") String hunterUuid){
        return hunterService.getHunterService(hunterUuid);
    }

    /**
     * 根据status返回猎人列表
     * @param hunterStatus
     * @return
     */
    @RequestMapping(value = "/listHunter",method = RequestMethod.POST)
    public ResultUtil<Object> listHunter(@RequestParam("hunterStatus") int hunterStatus,
                                         @RequestParam("startPage") Integer startPage,
                                         @RequestParam("endPage") Integer endPage){
        return hunterService.listHunterService(hunterStatus,startPage,endPage);
    }

    /**
     * 猎人钱包存款减少(提现)
     * @param
     * @return
     */
    @RequestMapping(value = "/hunterWalletReduce",method = RequestMethod.POST)
    public ResultUtil<Object> hunterWalletReduce(@RequestParam("hunterUuid") String hunterUuid,
                                                 @RequestParam("wallet") double wallet){
        return hunterService.hunterWalletReduceService(hunterUuid,wallet);
    }
}
